<template>
  <div>
    <partial-view v-ref:pv>
      <div class="flex">
        <p class="bg-info text-center" style="padding: 8px;">汇总信息分析</p>
        <div class="form-inline auto" v-if="tablename === 't_sellinggas'">
          <label for="f_pregas" class=" col-sm-3 control-label">汇总类型:</label>
          <div class="col-sm-6">
            <v-select id="f_sum_state"
            v-model="sum_state"
            :value.sync="sum_state"
            :options='sumState'
            close-on-select clear-button>
            </v-select>
          </div>
        </div>
        <div class="span">
          <usegas-type :condition='condition' :tablename='tablename' v-if="tablename === 't_userinfo'"></usegas-type>
          <sell-typechart :condition='condition' :tablename='tablename' :sum_state='sum_state' v-if="tablename === 't_sellinggas'"></sell-typechart>
          <hand-play :condition='condition' :tablename='tablename' v-if="tablename === 't_handplan'"></hand-play>
          <record :condition='condition' :tablename='tablename' v-if="tablename === 't_record'"></record>
          <other-sum :condition='condition' :tablename='tablename'
          v-if="!(tablename === 't_userinfo' || tablename === 't_sellinggas' || tablename === 't_handplan' ||tablename === 't_record')">
        </other-sum>
        </div>
      </div>
    </partial-view>
  </div>

</template>

<script>
// import echarts from 'echarts'
import AppData from '../../../../stores/AppData'
export default {
  title: '信息汇总',
  props: ['tabactive', 'condition'],
  data () {
    return {
      model: {},
      tablename: '',
      imname: '',
      sum_state: ['付款方式']
    }
  },
  computed: {
    sumState() {
      return AppData.getParam('收费信息分类类型')
    }
  },

  methods: {
    trimdata () {
      let val = this.tabactive
      for (let key in val) {
        if (val[key] === true) {
          this.$info(`切换到标签: ${key}`)
          this.imname = key.split('__')[0]
          // 获取表名
          if (key.split('__')[1] === 'tab') {
            this.tablename = 't_' + key.split('__')[0]
          } else if (key.split('__')[1] === 'view') {
            this.tablename = 'V_' + key.split('__')[0]
          }
        }
      }
    }
  },
  watch: {
    'tabactive': {
      deep: true,
      handler (val) {
        this.trimdata()
      }
    }
    },
  ready () {

     this.trimdata()
   }
}
</script>
